package com.tomcat;

import com.aliyun.fc.runtime.Context;
import example.App;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FcServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    Context context = new FcContext();

    public FcServlet(App app) {
        this.app = app;
    }

    App app = null;

    public void init() {
        System.out.println("执行了init方法");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) {
        try {
            app.handleRequest(request, response, context);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) {
        doGet(request, response);
    }
}
